<?php
class UserLanguage 
{
	/**
	 *  Datenbankverbindung
	 *  @var Kanedo_Db
	 */
	protected $_db = null;
	
	protected $_table;
	protected $_tablePk;
	/**
	 * Konstrukt
	 *
	 * @param Kanedo_Db $db
	 * @param string $table
	 * @param string $pk
	 */
	public function __construct(Kanedo_Db $db, $table = "user_config", $pk = "id_user_config")
	{
		$this->_db = $db;
		if (!$this->_db->isConnected())
		{
			throw new Kanedo_Db_Exception("No connection to DB found!");
		}
		$this->_table = $table;
		$this->_tablePk = $pk;
	}
	
	public function getUserLanguageById($id, $userPk = "user_user_id_user_user")
	{
		$sql = "SELECT `lang` FROM `".$this->_table."` WHERE `".$userPk."` = ".$id;
		$result = $this->_db->executeQuery($sql);
		$data = $this->_db->fetchAll($result);
		return $data[0]['lang'];
	}
}
?>